functor X86AsmMain (S : X86ASM_MAIN_STRUCTS) : X86ASM_MAIN =
struct
  open S
  
  structure Machine = Machine
  structure X86Asm = X86Asm
  
  structure X86Asmize = X86Asmize (structure Machine = Machine
                                   structure X86Asm = X86Asm)
                                   
  structure X86AsmizeRa = X86AsmizeRa (structure Machine = Machine
                                       structure X86Asm = X86Asm)
  
  datatype t
    = Ra
    | NoRa
                               
  fun trans f =
      let val (new, path) = if !Control.doRaOpt
                    then (X86AsmizeRa.trans f, Ra)
                    else (X86Asmize.trans f, NoRa)
          val str = X86Asm.Program.toString new
          val _ = case path
                   of NoRa =>
                      File.output (String.concat [File.nameToString (!ErrorMsg.file), ".s"], str)
                    | Ra =>
                      File.output (String.concat [File.nameToString (!ErrorMsg.file), ".s"], str)
          val _ = File.output (String.concat ["sss.s"], str)
      in  new
      end
  
end
